<template >

<el-form style="max-width: 600px;margin-top:10px;" :model="createForm" :rules="rules" label-width="auto"
    class="form_style" :size="formSize" status-icon>
    <h2>添加分类
      <span>请在下面如实填写店铺信息，其中星号为必填项</span>
    </h2>
    <el-form-item   label="抽成比例：" prop="brokerage" >
          <el-input v-model="createForm.brokerag"/>
      </el-form-item>
     <el-form-item   label="关键字：" prop="keywords" >
          <el-input v-model="createForm.keywords "/>
      </el-form-item>
      <el-form-item   label="分类级别：" prop="level" >
          <el-input v-model="createForm.level "/>
      </el-form-item>
      <el-form-item label="货品类别名：" prop="name">
        <el-input v-model="createForm.name"/>
      </el-form-item>
      <el-form-item label="备注信息：" prop="note">
        <el-input v-model="createForm.note" type="textarea"/>
      </el-form-item>
      <el-form-item label="上级分类：" prop="parentId">
        <el-input v-model="createForm.parentId"/>
      </el-form-item>
      <el-form-item label="显示状态：" prop="showStatus">
        <el-input v-model="createForm.showStatus"/>
      </el-form-item>
      <el-form-item label="排序：" prop="sort">
        <el-input v-model="createForm.sort"/>
      </el-form-item>
      <el-button type="primary" style="margin-left: 50%;" @click="confirm()">提交</el-button>
      </el-form>
     </template>
<script lang="ts" setup>
import { reactive, ref } from 'vue'
import type {FormRules } from 'element-plus'
import {createProdCategory} from '../../../api';

const createForm = ref({
  brokerag: null,
  keywords: '',
  level: null,
  name: '',
  navStatus: null,
  note: '',
  parentId: null,
  showStatus: null,
  sort:null
})

const confirm = async () => {
  console.log('更新内容', createForm)
  console.log('更新内容', createForm.value)
  let response = createForm.value
  //把updateForm.value给列表的第一列
  console.log('更新内容', response)
  let res = await createProdCategory(createForm.value);
  console.log('查看一下', createForm)
  console.log('查看一下2', res)
  if (res.code == 200) {
    ElMessage({
      message: '添加成功',
      type: 'success',
      duration: 1000
    });
  } else {
    ElMessage({
      message: res.message,
      type: 'error',
      duration: 1000
    });
  }
  dialogFormVisible.value = false
}



const rules = reactive<FormRules<RuleForm>>({
 level: [
    { required: true, message: 'Please input Activity name', trigger: 'blur' },
    { min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
  ],
  product_category_id: [
    {
      //true添加星号
      required: true,
      message: 'Please select Activity zone',
      trigger: 'change',
    },
  ],
  product_category_name: [
    {
      required: true,
      message: 'Please select Activity count',
      trigger: 'change',
    },
  ],
  note: [
    {
      type: 'date',
      // required: true,
      message: 'Please pick a date',
      trigger: 'change',
    },
  ],
  keywords: [
    {
      type: 'date',
      required: true,
      message: 'Please pick a time',
      trigger: 'change',
    },
  ],
})



</script>
<style scoped>
/* 表单的样式 */
.form_style {
  margin-left: auto;
  margin-right: auto;
  max-width: 500px;
  background: #FFF;
  padding: 30px 30px 20px 30px;
  box-shadow: rgba(187, 187, 187, 1) 0 0px 20px -1px;
  -webkit-box-shadow: rgba(187, 187, 187, 1) 0 0px 20px -1px;
  font: 12px Arial, Helvetica, sans-serif;
  color: #666;
  border-radius: 10px;
  -webkit-border-radius: 10p
}

/*大标题样式*/
.form_style h2 {
  font: 24px "Trebuchet MS", Arial, Helvetica, sans-serif;
  padding: 0px 0px 10px 40px;
  display: block;
  border-bottom: 1px solid #F5F5F5;
  margin: -10px -30px 10px -30px;
  color: #354552;
}

/*小标题样式*/
.form_style h2>span {
  display: block;
  font-size: 12px;
}
</style>